package com.lanlian.cayman.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;

import com.lanlian.commonlib.bean.RegisterEnumInfo;
import com.lanlian.cayman.R;
import com.lanlian.utillib.DisplayUtil;

import java.util.ArrayList;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/11/8 14:27
 *     desc   : todo
 *     version: 1.0
 * </pre>
 */
public class SelectAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<RegisterEnumInfo> mList;
    private int mChoiceMode;

    public SelectAdapter(Context mContext, ArrayList<RegisterEnumInfo> mList, int choiceMode) {
        this.mContext = mContext;
        this.mList = mList;
        this.mChoiceMode = choiceMode;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LinearLayout.inflate(mContext, R.layout.adapter_multi_select, null);
        }
        CheckedTextView mCtItem = convertView.findViewById(R.id.tv_item);
        if (mChoiceMode == AbsListView.CHOICE_MODE_MULTIPLE) {
            mCtItem.setCheckMarkDrawable(R.drawable.radio_style5_selector);
        } else {
            mCtItem.setCheckMarkDrawable(R.drawable.radio_style7_selector);
        }
        mCtItem.setHeight(DisplayUtil.dip2px(mContext, 50));
        mCtItem.setText(mList.get(position).getContent());
        return convertView;
    }
}
